import javax.jms.*;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;

public class producer {

    private static String url = ActiveMQConnection.DEFAULT_BROKER_URL;

    public static void main(String[] args) throws JMSException {

        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        // JMS messages are sent and received using a Session. We will
        // create here a non-transactional session object. If you want
        // to use transactions you should set the first parameter to 'true'
        Session session = connection.createSession(false,
                Session.AUTO_ACKNOWLEDGE);

        Topic topic = session.createTopic("MessagesTopics");

        MessageProducer producer = session.createProducer(topic);


        TextMessage message = session.createTextMessage();

        for(int i = 0;i<100;i++){
        	message.setText("message texte "+ i);
        	producer.send(message);
        	System.out.println("Sent message '" + message.getText() + "'");
        }
        
        


        connection.close();
    }
}